home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
UPC12BS1.ZIP
/
LIB
/
IMPORT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-27
|
35KB
|
860 lines
/*--------------------------------------------------------------------*/
/* i m p o r t . c */
/* */
/* File name mapping routines for UUPC/extended */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Changes Copyright (c) 1989 by Andrew H. Derbyshire. */
/* */
/* Changes Copyright (c) 1990-1993 by Kendra Electronic */
/* Wonderworks. */
/* */
/* All rights reserved except those explicitly granted by the */
/* UUPC/extended license agreement. */
/*--------------------------------------------------------------------*/
/*
* $Id: import.c 1.9 1993/09/27 04:04:06 ahd Exp $
*
* $Log: import.c $
* Revision 1.9 1993/09/27 04:04:06 ahd
* Correct creation of pointer to file system name
*
* Revision 1.8 1993/09/26 03:32:27 dmwatt
* Use Standard Windows NT error message module
*
* Revision 1.7 1993/09/20 04:38:11 ahd
* TCP/IP support from Dave Watt
* 't' protocol support
* OS/2 2.x support
*
* Revision 1.6 1993/09/03 12:54:55 ahd
* Add missing endif
*
* Revision 1.5 1993/09/03 12:18:55 dmwatt
* Windows NT support for long names on file systems
*
* Revision 1.4 1993/09/02 12:08:17 ahd
* HPFS Support
*
* Revision 1.3 1993/04/11 00:31:31 dmwatt
* Global edits for year, TEXT, etc.
*
* Revision 1.2 1992/11/22 21:06:14 ahd
* Correct mapping of dos paths with trailing slashes
*
*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if defined(FAMILYAPI) || defined(__OS2__)
#define INCL_NOPM // No need to include OS/2 PM info
#define INCL_BASE
#include <os2.h>
#elif defined(WIN32)
#include <windows.h>
#endif
/*--------------------------------------------------------------------*/
/* UUPC/extended include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "import.h"
#include "arbmath.h"
#include "hostable.h"
#include "usertabl.h"
#include "security.h"
#ifdef WIN32
#include "pnterr.h"
#endif
#define MAX_DIGITS 20 /* Number of digits for arb math */
/*--------------------------------------------------------------------*/
/* Internal function prototypes */
/*--------------------------------------------------------------------*/
#define min(x,y) (((x) < (y)) ? (x) : (y))
currentfile();
/*--------------------------------------------------------------------*/
/* Local function prototypes */
/*--------------------------------------------------------------------*/
static void ImportName( char *local,
const char *canon,
size_t charsetsize,
const boolean longname );
static boolean advancedFS( const char *path );
/*-------------------------------------------------------------------*/
/* */
/* i m p o r t p a t h */
/* */
/* Convert a canonical name to a format the host can handle */
/* */
/* These routines convert file name between canonical form, which */
/* is defined as a 'unix' style pathname, and the MS-DOS all */
/* uppercase "xxxxxxxx.xxx" format. */
/* */
/* If the canonical name does not have a path, that is the file is */
/* destined for the local spool directory, we can assume the UNIX */
/* name will normally be in a format like this: */
/* */
/* */
/* X.hostid####### (Execute files) */
/* C.hostid####### (Call files) */
/* D.hostid####### (Data files) */
/* */
/* where "hostid" may be most, but not always all, of the local */
/* host or remote host (the file came from or is going to) and */
/* "######" can be any character valid for the UNIX file system. */
/* Note, however, that the routine has to be generic to allow for */
/* other file names to be placed in the spool directory without */
/* collisions. */
/* */
/* Avoiding collisions in the spool directory is important; when */
/* receiving files with mixed case names longer than 11 */
/* characters, sooner or later a file name collision will occur. */
/* */
/* We can also assume that only UUPC will see these names, which */
/* means we can transform the name using any method we choose, so */
/* long as the UUPC functions opening the file always call */
/* importpath, and that importpath is reducible (that is, two */
/* calls to importpath with the same argument always yield the */
/* same result). Note that if end user really wanted the file in */
/* the spool directory, all he has to do is rename the file-- far */
/* better than losing the data because duplicate file names. */
/* */
/* For these files, we map the name as follows: */
/* */
/* 0 - If the name is a valid MS-DOS name, use it without changing */
/* */
/* 1 - Begin the output name by inserting up to the first eight */
/* characters of the remote host name (followed by a slash) as */
/* a subdirectory name. */
/* */
/* 2 - If the input name begins with an uppercase alphabetic */
/* character followed by a period, also insert the alphabetic */
/* (followed by a slash) to make this a second subdirectory. */
/* Then, move the logical start of the input name past the two */
/* characters. */
/* */
/* 3 - Determine the number of characters the local host and */
/* remote hosts have equal to the next characters of the input */
/* name, up to a maximum of 8, and zero the lower of the two */
/* counts. Then, step past the number of characters of the */
/* larger count. */
/* */
/* For example, if the file name is X.keane22222 and the local */
/* host name is kendra (2 characters match) and the remote */
/* host is keane1 (5 characters mat